﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using StructureMap;
using StructureMap.Configuration;
using StructureMap.Configuration.DSL;
using DLM.Domain.Repositories;
using DLM.Infrastructure.UnitOfWork;
using DLM.Infrastructure.Logging;
using DLM.Infrastructure.Domain;
using DLM.Infrastructure.Configuration;
using DLM.Infrastructure.Authentication;
using DLM.Services.Interfaces;
using DLM.Services.Implementations;
using DLM.Services.BonusRule;

namespace DLM.DependencyResolve
{
    public class BaseHttpApplication : HttpApplication
    {
        static BaseHttpApplication()
        {
            BootStrapper.ConfigureDependencies();
            ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory());

            // Initialization interface
            ApplicationSettingsFactory.InitializeApplicationSettingsFactory
                         (ObjectFactory.GetInstance<IApplicationSettings>());

            LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance<ILogger>());

            BonusRuleFactory.InitBonusRuleFactory(ObjectFactory.GetInstance<IBonusRuleService>());

            LoggingFactory.GetLogger().Log("Application start!");

            Schedule.SchedulerFactory.InitializeConfig();
        }

        protected void InitializeFactory()
        {
       
            // ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory());
        }
    }
}
